home *** CD-ROM | disk | FTP | other *** search
/ Hello Kitty - Big Fun Shapes & Numbers / Hello Kitty - Big Fun Shapes & Numbers (USA).bin / mac / _MATH / 00415.ls < prev    next >
Encoding:
Text File  |  1995-05-08  |  23.4 KB  |  899 lines

  1. on startMovie
  2.   global background, HiderSpr, level, levelSpr, aCharacterInfo, firstCharacterSpr, lBack, tBack, rBack, bBack, gNumber, gNumber2, groupRoster, numCharacters, numChar, hiderX, hiderY, CardSpr, timerWait, answer, counterSpr, SceneSpr, spriteInAction, arrowSpr, extraHiderSpr, attempts, numCorrect, nextSound, idleStr, numCorrect4Lev2, numCorrect4Lev3, CountString, SelectedAnswers, correctCounter2, numWrong, lastWrongAnswer, kprefPath, gMac, capObj
  3.   append(the searchPath, kprefPath & "hknumber\")
  4.   if the machineType = 256 then
  5.     set gMac to 0
  6.   else
  7.     set gMac to 1
  8.   end if
  9.   makeAFolder("hkNumber")
  10.   if gMac then
  11.     if objectp(capObj) then
  12.       capObj(mdispose)
  13.     end if
  14.     set capObj to maketemplate(mnew)
  15.   else
  16.     if objectp(capObj) then
  17.       set capObj to capObj(mdispose)
  18.     end if
  19.     set capObj to Draw(mnew)
  20.   end if
  21.   set background to 2
  22.   set HiderSpr to 3
  23.   set CardSpr to 19
  24.   set levelSpr to 5
  25.   set firstCharacterSpr to 6
  26.   set counterSpr to 21
  27.   set extraHiderSpr to 20
  28.   set arrowSpr to 22
  29.   set SceneSpr to 23
  30.   set CountString to EMPTY
  31.   set SelectedAnswers to EMPTY
  32.   set hiderX to 256
  33.   set hiderY to 227
  34.   puppetSprite(background, 1)
  35.   puppetSprite(CardSpr, 1)
  36.   puppetSprite(levelSpr, 1)
  37.   puppetSprite(arrowSpr, 1)
  38.   puppetSprite(counterSpr, 1)
  39.   puppetSprite(SceneSpr, 1)
  40.   puppetSprite(extraHiderSpr, 1)
  41.   set str to getGameLevel()
  42.   if stringp(str) then
  43.     set level to integer(word 1 of str)
  44.     if (level < 1) or (level > 3) then
  45.       set level to 1
  46.     end if
  47.     if level > 1 then
  48.       takeOffArrows()
  49.     end if
  50.     set numCorrect4Lev2 to integer(word 2 of str)
  51.     set numCorrect4Lev3 to integer(word 3 of str)
  52.     if level = 2 then
  53.       set numCorrect to numCorrect4Lev2
  54.     end if
  55.     if level = 3 then
  56.       set numCorrect to numCorrect4Lev3
  57.     end if
  58.     if not integerp(numCorrect) or (numCorrect < 0) then
  59.       set numCorrect to 0
  60.     end if
  61.     set lastWrongAnswer to numCorrect
  62.   else
  63.     set level to 1
  64.     set numCorrect4Lev2 to 0
  65.     set numCorrect4Lev3 to 0
  66.     set numCorrect to 0
  67.     set lastWrongAnswer to 0
  68.   end if
  69.   set correctCounter2 to 0
  70.   set numWrong to 0
  71.   set the castNum of sprite levelSpr to the number of cast ("level" & (level * 2) - 1)
  72.   set numCharacters to "0 0 0"
  73.   set numChar to 0
  74.   set answer to 0
  75.   set attempts to 0
  76.   set nextSound to EMPTY
  77.   set lBack to the left of sprite background
  78.   set tBack to the top of sprite background
  79.   set rBack to the right of sprite background
  80.   set bBack to the bottom of sprite background
  81.   set the immediate of sprite levelSpr to 1
  82.   put " " into field "Entry"
  83.   set the textSize of field "Entry" to 24
  84.   set the textStyle of field "Entry" to "bold"
  85.   set timerWait to 0
  86.   set n to 3
  87.   if random(3) = 1 then
  88.     set n to random(2)
  89.   end if
  90.   NewScene(n, 1)
  91.   setGroup(3)
  92.   initCard()
  93.   set idleStr to EMPTY
  94. end
  95.  
  96. on idle
  97.   global idleStr
  98.   do(idleStr)
  99. end
  100.  
  101. on stopMovie
  102.   global level, idleStr, numCorrect4Lev2, numCorrect4Lev3, numCorrect, returningFromMovie, gameLevels, capObj, gMac, oldColDepth, kPCflag, kCDvol, kprefPath
  103.   set the searchPath to []
  104.   set idleStr to EMPTY
  105.   if level = 2 then
  106.     set numCorrect4Lev2 to numCorrect
  107.   end if
  108.   if level = 3 then
  109.     set numCorrect4Lev3 to numCorrect
  110.   end if
  111.   set level to 1
  112.   set str to level && numCorrect4Lev2 && numCorrect4Lev3
  113.   setGameLevel(str)
  114.   if gMac then
  115.     if objectp(capObj) then
  116.       capObj(mdispose)
  117.     end if
  118.   else
  119.     if objectp(capObj) then
  120.       set capObj to capObj(mdispose)
  121.     end if
  122.   end if
  123.   set g to gameLevels
  124.   set o to oldColDepth
  125.   set pc to kPCflag
  126.   set cd to kCDvol
  127.   set p to kprefPath
  128.   clearGlobals()
  129.   set gameLevels to g
  130.   set oldColDepth to o
  131.   set kPCflag to pc
  132.   set kCDvol to cd
  133.   set kprefPath to p
  134.   set returningFromMovie to 1
  135.   unLoad()
  136. end
  137.  
  138. on NewScene n, noSoundFlag
  139.   global scene, background, groupRoster, gNumber, gName, gName2, numChar, numCharacters
  140.   set scene to n
  141.   setSceneButton()
  142.   set groupRoster to item scene of "apple bird bunny,bubble flower mush,duck bfly rose"
  143.   set gNumber to random(3)
  144.   set gName to word gNumber of groupRoster
  145.   set numCharacters to "0 0 0"
  146.   set numChar to 0
  147.   defaultBackground()
  148.   set the castNum of sprite background to the number of cast ("Scene" & scene)
  149.   if not integerp(noSoundFlag) then
  150.     playSound("MagicAppearance", 1)
  151.   end if
  152. end
  153.  
  154. on changeGroup n
  155.   global gNumber
  156.   set g to gNumber
  157.   set g to g + n
  158.   if g > 3 then
  159.     set g to 1
  160.   end if
  161.   if g < 1 then
  162.     set g to 3
  163.   end if
  164.   setGroup(g)
  165. end
  166.  
  167. on setGroup n
  168.   global numCharacters, gName, gNumber, numChar, groupRoster
  169.   put numChar into word gNumber of numCharacters
  170.   set gNumber to n
  171.   set gName to word gNumber of groupRoster
  172.   set numChar to value(word gNumber of numCharacters)
  173. end
  174.  
  175. on doEquation
  176.   global numChar, SelectedAnswers, level
  177.   set desiredSum to getEquation()
  178.   if level = 2 then
  179.     set count to 0
  180.     repeat while (numChar = desiredSum) or (SelectedAnswers contains " " & desiredSum)
  181.       set desiredSum to getEquation()
  182.       set count to count + 1
  183.       if count > 20 then
  184.         set SelectedAnswers to EMPTY
  185.         exit repeat
  186.       end if
  187.     end repeat
  188.     put " " & desiredSum after SelectedAnswers
  189.   end if
  190.   if desiredSum < numChar then
  191.     Subtraction(desiredSum)
  192.   else
  193.     Addition(desiredSum)
  194.   end if
  195. end
  196.  
  197. on getEquation
  198.   global numCorrect, numChar
  199.   set arg1 to 3
  200.   if numCorrect < 3 then
  201.     set base to 0
  202.   end if
  203.   if (numCorrect >= 3) and (numCorrect < 9) then
  204.     set base to 3
  205.   end if
  206.   if numCorrect >= 9 then
  207.     set base to 6
  208.     set arg1 to 4
  209.   end if
  210.   set desiredSum to numChar
  211.   repeat while desiredSum = numChar
  212.     set desiredSum to random(arg1) + base
  213.     if (random(3) = 1) and (base > 0) then
  214.       set desiredSum to random(base + arg1)
  215.     end if
  216.     if desiredSum > 10 then
  217.       set desiredSum to 10
  218.     end if
  219.   end repeat
  220.   return desiredSum
  221. end
  222.  
  223. on Addition desiredSum
  224.   global level, numChar, gNumber, numCharacters, addSubSign, randomSet, lastEquation, CountString
  225.   set CountString to EMPTY
  226.   set addSubSign to "Addition"
  227.   set r to desiredSum - numChar
  228.   bringCharacter(r)
  229.   put numChar into word gNumber of numCharacters
  230.   go(label("level" & level) + 1)
  231. end
  232.  
  233. on Subtraction desiredSum
  234.   global level, numChar, gNumber, numCharacters, addSubSign, lastEquation
  235.   set addSubSign to "Addition"
  236.   set r to numChar - desiredSum
  237.   set tryCounter to 0
  238.   set thisEquation to numChar - r && r && numChar
  239.   repeat while thisEquation = lastEquation
  240.     set r to random(numChar - 1)
  241.     set thisEquation to numChar - r && r && numChar
  242.     set tryCounter to tryCounter + 1
  243.     if tryCounter > 30 then
  244.       Addition()
  245.       exit
  246.     end if
  247.   end repeat
  248.   takeAwayCharacter(r)
  249.   put numChar into word gNumber of numCharacters
  250.   go(label("level" & level) + 1)
  251. end
  252.  
  253. on bringCharacter num
  254.   global numChar, firstCharacterSpr, gName, spriteInAction, CountString
  255.   set loopBegin to numChar + 1
  256.   set loopEnd to numChar + num
  257.   if loopEnd > 10 then
  258.     set loopEnd to 10
  259.   end if
  260.   if loopBegin > 10 then
  261.     set loopBegin to 10
  262.   end if
  263.   puppetSound(0)
  264.   repeat with i = loopBegin to loopEnd
  265.     set CountString to EMPTY
  266.     set spriteInAction to firstCharacterSpr + i - 1
  267.     play frame gName & i & "Enter"
  268.     puppetSprite(firstCharacterSpr + i - 1, 1)
  269.     set numChar to numChar + 1
  270.   end repeat
  271.   grabBackground()
  272.   set spriteInAction to 0
  273.   turncharactersoff()
  274. end
  275.  
  276. on takeAwayCharacter num
  277.   global numChar, firstCharacterSpr, tempGlobalUsage, gName, spriteInAction, CountString
  278.   set beginLoop to numChar + 1
  279.   puppetSound(0)
  280.   repeat with i = 1 to num
  281.     set CountString to EMPTY
  282.     set j to beginLoop - i
  283.     set tempGlobalUsage to j
  284.     set spriteInAction to 11 - j + firstCharacterSpr - 1
  285.     play frame gName & j & "Out"
  286.     makeCharInvisible(j)
  287.     set numChar to numChar - 1
  288.   end repeat
  289.   grabBackground()
  290.   removehider()
  291.   set spriteInAction to 0
  292.   turncharactersoff()
  293. end
  294.  
  295. on makeCharInvisible i
  296.   global firstCharacterSpr, gNumber, gName, hiderX, hiderY
  297.   set Sprt to firstCharacterSpr + 10 - i
  298.   puppetSprite(Sprt, 1)
  299.   set the castNum of sprite Sprt to the number of cast (gName & i & ".erase")
  300.   set the locH of sprite Sprt to hiderX
  301.   set the locV of sprite Sprt to hiderY
  302.   updateStage()
  303. end
  304.  
  305. on grabBackground
  306.   global scene, lBack, tBack, rBack, bBack
  307.   captureArea("Scene" & scene, lBack, tBack, rBack, bBack)
  308. end
  309.  
  310. on defaultBackground
  311.   global scene
  312.   set the picture of cast ("Scene" & scene) to the picture of cast ("Scene" & scene & "Default")
  313. end
  314.  
  315. on captureArea cName, l, t, r, b
  316.   global capObj, kprefPath, gMac
  317.   if gMac then
  318.     set the picture of cast cName to capObj(mStageToCast, l, t, r, b)
  319.   else
  320.     set capturePath to kprefPath & "hknumber\capture.dib"
  321.     set result to capObj(mStageToDIB, capturePath, l, t, r, b)
  322.     set result to LoadDIBIntoCast(capturePath, cName)
  323.   end if
  324. end
  325.  
  326. on LoadDIBIntoCast fileName, cName
  327.   set cNum to the number of cast cName
  328.   if cNum = -1 then
  329.     alert(QUOTE & cName & QUOTE & " cast not found")
  330.   end if
  331.   set cPal to the palette of cast cNum
  332.   set cScript to the scriptText of cast cNum
  333.   set the fileName of cast "linked pic" to fileName
  334.   set the picture of cast cNum to the picture of cast "linked pic"
  335.   set result to 1
  336.   if the castType of cast cNum <> #bitmap then
  337.     alert("Error loading bitmap :" & fileName)
  338.     move(cast "empty bitmap", cast cNum)
  339.     set result to 0
  340.   end if
  341.   return result
  342. end
  343.  
  344. on hidecharacter characterNum
  345.   global HiderSpr, hiderX, hiderY, gName
  346.   puppetSprite(HiderSpr, 1)
  347.   set the castNum of sprite HiderSpr to the number of cast (gName & characterNum & ".erase")
  348.   set the locH of sprite HiderSpr to hiderX
  349.   set the locV of sprite HiderSpr to hiderY
  350.   updateStage()
  351. end
  352.  
  353. on clearTheDecks
  354.   global counterSpr
  355.   puppetSprite(24, 0)
  356.   turncharactersoff()
  357.   when keyDown then nothing
  358.   set the castNum of sprite 16 to the number of cast "standard kitty"
  359.   set the locH of sprite 16 to 417
  360.   set the locV of sprite 16 to 297
  361.   set the locH of sprite counterSpr to -256
  362.   set the locH of sprite 4 to -256
  363.   puppetSprite(4, 0)
  364.   set the locH of sprite 17 to -256
  365.   set the locH of sprite 18 to -256
  366.   removehider()
  367.   removeextrahider()
  368.   if the castNum of sprite 19 = the number of cast "answerHold" then
  369.     set the locH of sprite 19 to 276 - 512
  370.     set the locV of sprite 19 to 45
  371.   end if
  372. end
  373.  
  374. on removehider
  375.   global HiderSpr
  376.   set the locH of sprite HiderSpr to -300
  377.   updateStage()
  378.   puppetSprite(HiderSpr, 0)
  379. end
  380.  
  381. on hide cName
  382.   global HiderSpr, hiderX, hiderY, gName
  383.   puppetSprite(HiderSpr, 1)
  384.   set the castNum of sprite HiderSpr to the number of cast cName
  385.   set the locH of sprite HiderSpr to hiderX
  386.   set the locV of sprite HiderSpr to hiderY
  387.   updateStage()
  388. end
  389.  
  390. on eraseCharacters
  391.   global HiderSpr, hiderX, hiderY, gName
  392.   puppetSprite(HiderSpr, 1)
  393.   set the trails of sprite HiderSpr to 1
  394.   repeat with i = 1 to 10
  395.     set the castNum of sprite HiderSpr to the number of cast (gName & i & ".erase")
  396.     set the locH of sprite HiderSpr to hiderX
  397.     set the locV of sprite HiderSpr to hiderY
  398.     updateStage()
  399.   end repeat
  400.   set the trails of sprite HiderSpr to 0
  401. end
  402.  
  403. on resetStage
  404.   global firstCharacterSpr
  405.   repeat with i = 1 to 10
  406.     set C to firstCharacterSpr + i - 1
  407.     if the castNum of sprite C then
  408.       set the locH of sprite C to -512
  409.       puppetSprite(C, 0)
  410.     end if
  411.   end repeat
  412.   updateStage()
  413. end
  414.  
  415. on FlipCard toStr
  416.   global gName, CardSpr
  417.   set cName to the name of cast the castNum of sprite CardSpr
  418.   if not stringp(toStr) then
  419.     set toStr to EMPTY
  420.   end if
  421.   if cName = "NumberCard" then
  422.     if toStr contains "Number" then
  423.       return 0
  424.     end if
  425.     set flipStr to "NumberFlip.1,NumberFlip.2,CardFlip.2,CardFlip.1," & gName & "Card"
  426.   else
  427.     if toStr = "CardToCard" then
  428.       set flipStr to "CardFlip.1,CardFlip.2,revCardFlip.2,revCardFlip.1," & gName & "Card"
  429.     else
  430.       if toStr contains "Card" then
  431.         return 0
  432.       end if
  433.       set flipStr to "CardFlip.1,CardFlip.2,NumberFlip.2,NumberFlip.1,NumberCard"
  434.     end if
  435.   end if
  436.   puppetSound("cardFlip")
  437.   repeat with i = 1 to the number of items in flipStr
  438.     set fStr to item i of flipStr
  439.     set the castNum of sprite CardSpr to the number of cast fStr
  440.     updateStage()
  441.     wait(3)
  442.   end repeat
  443.   return 1
  444. end
  445.  
  446. on getcardCharacter
  447.   global CardSpr
  448.   set cName to the name of cast the castNum of sprite CardSpr
  449.   set cardChar to char 1 to offset("card", cName) - 1 of cName
  450.   return cardChar
  451. end
  452.  
  453. on hideCardSpr
  454.   global CardSpr
  455.   if the locH of sprite CardSpr > 0 then
  456.     set the locH of sprite CardSpr to the locH of sprite CardSpr - 512
  457.   end if
  458. end
  459.  
  460. on showCardSpr
  461.   global CardSpr
  462.   if the locH of sprite CardSpr < 0 then
  463.     set the locH of sprite CardSpr to the locH of sprite CardSpr + 512
  464.   end if
  465. end
  466.  
  467. on initCard
  468.   global CardSpr, gName
  469.   set the castNum of sprite CardSpr to the number of cast (gName & "Card")
  470. end
  471.  
  472. on formatName str, num
  473.   set dispName to EMPTY
  474.   if not integerp(num) then
  475.     set num to 2
  476.   end if
  477.   if num = 1 then
  478.     if str = "bunny" then
  479.       set dispName to "bunny"
  480.     end if
  481.     if str = "apple" then
  482.       set dispName to "apple"
  483.     end if
  484.     if str = "bird" then
  485.       set dispName to "bird"
  486.     end if
  487.     if str = "mush" then
  488.       set dispName to "mushroom"
  489.     end if
  490.     if str = "bubble" then
  491.       set dispName to "bubble"
  492.     end if
  493.     if str = "flower" then
  494.       set dispName to "flower"
  495.     end if
  496.     if str = "duck" then
  497.       set dispName to "duck"
  498.     end if
  499.     if str = "bfly" then
  500.       set dispName to "butterfly"
  501.     end if
  502.     if str = "rose" then
  503.       set dispName to "flower"
  504.     end if
  505.   else
  506.     if str = "bunny" then
  507.       set dispName to "bunnies"
  508.     end if
  509.     if str = "apple" then
  510.       set dispName to "apples"
  511.     end if
  512.     if str = "bird" then
  513.       set dispName to "birds"
  514.     end if
  515.     if str = "mush" then
  516.       set dispName to "mushrooms"
  517.     end if
  518.     if str = "bubble" then
  519.       set dispName to "bubbles"
  520.     end if
  521.     if str = "flower" then
  522.       set dispName to "flowers"
  523.     end if
  524.     if str = "duck" then
  525.       set dispName to "ducks"
  526.     end if
  527.     if str = "bfly" then
  528.       set dispName to "butterflies"
  529.     end if
  530.     if str = "rose" then
  531.       set dispName to "flowers"
  532.     end if
  533.   end if
  534.   return dispName
  535. end
  536.  
  537. on turnOnCharacter num
  538.   global firstCharacterSpr, gName
  539.   turncharactersoff()
  540.   play frame label("All" & gName) + num - 1
  541.   repeat with i = 1 to num
  542.     puppetSprite(firstCharacterSpr + i - 1, 1)
  543.   end repeat
  544. end
  545.  
  546. on countCharacters
  547.   global firstCharacterSpr, numChar, counterSpr, CountString
  548.   turnOnCharacter(numChar)
  549.   if CountString <> EMPTY then
  550.     set str to CountString
  551.   else
  552.     set str to " " & firstCharacterSpr & " "
  553.     repeat with i = 2 to numChar
  554.       set n1 to firstCharacterSpr + i - 1
  555.       set flag to 0
  556.       repeat with j = 1 to the number of words in str
  557.         set n2 to value(word j of str)
  558.         if the left of sprite n1 < the left of sprite n2 then
  559.           put " " & n1 & " " before word j of str
  560.           set flag to 1
  561.           exit repeat
  562.         end if
  563.       end repeat
  564.       if flag = 0 then
  565.         put " " & n1 & " " after str
  566.       end if
  567.     end repeat
  568.   end if
  569.   CountDisplay(str)
  570.   set the locH of sprite counterSpr to -256
  571.   updateStage()
  572. end
  573.  
  574. on CharacterDance
  575.   global gName, numChar, firstCharacterSpr
  576.   turnOnCharacter(numChar)
  577.   hide(gName & "10.cover")
  578.   repeat with i = 1 to numChar
  579.     set C to firstCharacterSpr + i - 1
  580.     if the name of cast the castNum of sprite C contains "bunny1" then
  581.       set the castNum of sprite C to the number of cast "bunny1.1"
  582.     end if
  583.   end repeat
  584.   updateStage()
  585.   repeat with i = 1 to numChar
  586.     set C to firstCharacterSpr + i - 1
  587.     if the name of cast the castNum of sprite C contains "bunny1" then
  588.       set the castNum of sprite C to the number of cast "bunny1.2"
  589.     end if
  590.   end repeat
  591.   updateStage()
  592.   repeat with i = 1 to numChar
  593.     set C to firstCharacterSpr + i - 1
  594.     if the name of cast the castNum of sprite C contains "bunny1" then
  595.       set the castNum of sprite C to the number of cast "bunny1.1"
  596.     end if
  597.   end repeat
  598.   updateStage()
  599.   removehider()
  600.   turncharactersoff()
  601. end
  602.  
  603. on getCenter C
  604.   set l to the left of sprite C
  605.   set t to the top of sprite C
  606.   set r to the right of sprite C
  607.   set b to the bottom of sprite C
  608.   set x to l + ((r - l) / 2)
  609.   set y to t + ((b - t) / 2)
  610.   return x && y
  611. end
  612.  
  613. on CountDisplay str
  614.   global counterSpr, exitRepeat, level
  615.   repeat with i = 1 to the number of words in str
  616.     set spr to value(word i of str)
  617.     set x to the left of sprite spr + 10
  618.     set y to the top of sprite spr - 8
  619.     if y < 5 then
  620.       set y to the bottom of sprite spr + 8
  621.     end if
  622.     set the castNum of sprite counterSpr to the number of cast ("num" & i)
  623.     set the locH of sprite counterSpr to x
  624.     set the locV of sprite counterSpr to y
  625.     updateStage()
  626.     sayNum(i)
  627.   end repeat
  628. end
  629.  
  630. on hiliteOn spr
  631.   set the ink of sprite spr to 32
  632.   updateStage()
  633. end
  634.  
  635. on hiliteOff spr
  636.   set the ink of sprite spr to 8
  637.   updateStage()
  638. end
  639.  
  640. on getSprInfo start, num
  641.   set str to EMPTY
  642.   repeat with i = start to start + num - 1
  643.     set cName to the name of cast the castNum of sprite i
  644.     set x to the locH of sprite i
  645.     set y to the locV of sprite i
  646.     set str to str & cName & "," & x & "," & y & RETURN
  647.   end repeat
  648.   put str
  649. end
  650.  
  651. on turncharactersoff
  652.   global firstCharacterSpr
  653.   repeat with i = 1 to 10
  654.     set spr to firstCharacterSpr + i - 1
  655.     if the locH of sprite spr > 0 then
  656.       set the locH of sprite spr to -256
  657.     end if
  658.     puppetSprite(spr, 0)
  659.   end repeat
  660. end
  661.  
  662. on spritesOff
  663.   repeat with i = 1 to 27
  664.     puppetSprite(i, 0)
  665.   end repeat
  666. end
  667.  
  668. on formatInput
  669.   global nextSound
  670.   set n to the number of chars in field "Entry"
  671.   if ((the key = RETURN) or (the key = ENTER)) and (n > 0) then
  672.     dontPassEvent()
  673.     when keyDown then nothing
  674.     set the locH of sprite 4 to -256
  675.     updateStage()
  676.     checkAnswer(value(field "Entry"))
  677.     exit
  678.   end if
  679.   if ((the key < "0") or (the key > "9") or (n = 2)) and (the key <> BACKSPACE) then
  680.     dontPassEvent()
  681.   end if
  682.   set nextSound to EMPTY
  683. end
  684.  
  685. on checkAnswer userInput
  686.   global answer, level, scene, attempts, numCorrect, gName, gName2, lastWrongAnswer, gNumber2, numCharacters, numChar, numWrong, SelectedAnswers, correctCounter2
  687.   if userInput = answer then
  688.     set yeeyWord to item random(10) of "Correct,Excellent,Fantastic,Very Good,You Are Wonderful,Fabulous,Good Going,Good Job,That Was Great,Nice Counting"
  689.     if level = 2 then
  690.       put yeeyWord & "!" into field "display"
  691.     else
  692.       put RETURN & yeeyWord & "!" into field "display2"
  693.     end if
  694.     puppetSprite(24, 1)
  695.     if level = 2 then
  696.       playSound(yeeyWord, 1)
  697.       play frame gName & "Corrects"
  698.     else
  699.       captureArea("answerHold", 375, 18, 435, 57)
  700.       set x to the locH of sprite 19
  701.       set y to the locV of sprite 19
  702.       set C to the castNum of sprite 19
  703.       set the castNum of sprite 19 to the number of cast "answerHold"
  704.       set the locH of sprite 19 to 405
  705.       set the locV of sprite 19 to 37
  706.       playSound(yeeyWord, 1)
  707.       play frame gName & "Corrects"
  708.       set oldgName to gName
  709.       set oldnumChar to numChar
  710.       set numChar to integer(word gNumber2 of numCharacters)
  711.       set gName to gName2
  712.       play frame gName2 & "Corrects"
  713.       set gName to oldgName
  714.       set numChar to oldnumChar
  715.       set the locH of sprite 19 to x
  716.       set the locV of sprite 19 to y
  717.       set the castNum of sprite 19 to C
  718.     end if
  719.     puppetSprite(24, 0)
  720.     set attempts to 0
  721.     removehider()
  722.     set numCorrect to numCorrect + 1
  723.     if (numCorrect - lastWrongAnswer) >= 3 then
  724.       set numWrong to 0
  725.     end if
  726.     set correctCounter2 to correctCounter2 + 1
  727.     if correctCounter2 >= 10 then
  728.       set correctCounter2 to 0
  729.       ChangeLevel(1)
  730.     end if
  731.     go("level" & level)
  732.   else
  733.     set attempts to attempts + 1
  734.     if (attempts = 3) and (level > 1) then
  735.       set attempts to 0
  736.       set numWrong to numWrong + 1
  737.       set lastWrongAnswer to numCorrect
  738.       put EMPTY into word the number of words in SelectedAnswers of SelectedAnswers
  739.       go(level & "ShowAnswer")
  740.     else
  741.       play frame level & "tryAgain"
  742.       put EMPTY into field "Entry"
  743.       if level = 2 then
  744.         FlipCard("number")
  745.         go(label("level2") + 2)
  746.       else
  747.         if level = 3 then
  748.           go(label("level3") + 6)
  749.         end if
  750.       end if
  751.     end if
  752.   end if
  753. end
  754.  
  755. on ChangeLevel step
  756.   global level, levelSpr, scene, spriteInAction, numCorrect, numCorrect4Lev2, numCorrect4Lev3, numWrong
  757.   if (step = 1) and (level = 3) then
  758.     exit
  759.   end if
  760.   repeat with i = 1 to 2
  761.     set l to (level * 2) - 1 + (i * step)
  762.     set the castNum of sprite levelSpr to the number of cast ("level" & l)
  763.     playSound("crankTick", 1)
  764.   end repeat
  765.   if level = 2 then
  766.     set numCorrect4Lev2 to numCorrect
  767.   end if
  768.   if level = 3 then
  769.     set numCorrect4Lev3 to numCorrect
  770.   end if
  771.   set level to level + step
  772.   if level = 2 then
  773.     set numCorrect to numCorrect4Lev2
  774.   end if
  775.   if level = 3 then
  776.     set numCorrect to numCorrect4Lev3
  777.   end if
  778.   if not integerp(numCorrect) then
  779.     set numCorrect to 0
  780.   end if
  781.   set lastWrongAnswer to numCorrect
  782.   if (scene = 2) and the castNum of sprite 17 then
  783.     set the locH of sprite 4 to the locH of sprite 4 - 512
  784.     set the locH of sprite 17 to the locH of sprite 17 - 512
  785.     updateStage()
  786.   end if
  787.   if spriteInAction then
  788.     set the locH of sprite spriteInAction to -256
  789.     updateStage()
  790.     removehider()
  791.     grabBackground()
  792.     turncharactersoff()
  793.     put numChar into word gNumber of numCharacters
  794.   end if
  795.   clearTheDecks()
  796.   set numWrong to 0
  797. end
  798.  
  799. on nameCast b, e, prefix, Postfix
  800.   set loopB to value(b)
  801.   set loopE to value(e)
  802.   if not stringp(Postfix) then
  803.     set Postfix to EMPTY
  804.   end if
  805.   repeat with i = loopB to loopE
  806.     set n to i - loopB + 1
  807.     set the name of cast i to prefix & n & Postfix
  808.   end repeat
  809. end
  810.  
  811. on setSceneButton
  812.   global scene, SceneSpr
  813.   set the castNum of sprite SceneSpr to the number of cast ("Scene" & scene & "B")
  814.   updateStage()
  815. end
  816.  
  817. on doWait n
  818.   global waiter, waitFlag
  819.   set waiter to the timer + n
  820.   set waitFlag to 1
  821.   when mouseDown then exitWait()
  822.   play frame "wait"
  823. end
  824.  
  825. on exitWait
  826.   global waitFlag
  827.   set waitFlag to 0
  828.   when mouseDown then nothing
  829. end
  830.  
  831. on takeOffArrows
  832.   global arrowSpr
  833.   if the locH of sprite arrowSpr > 0 then
  834.     set the locH of sprite arrowSpr to the locH of sprite arrowSpr - 512
  835.   end if
  836. end
  837.  
  838. on bringOnArrows
  839.   global arrowSpr
  840.   if the locH of sprite arrowSpr < 0 then
  841.     set the locH of sprite arrowSpr to the locH of sprite arrowSpr + 512
  842.   end if
  843. end
  844.  
  845. on flipAllButOne num, arg1
  846.   global CardSpr, extraHiderSpr
  847.   set x to the locH of sprite CardSpr
  848.   set y to the locV of sprite CardSpr
  849.   set the ink of sprite extraHiderSpr to 0
  850.   set the castNum of sprite extraHiderSpr to the number of cast ("bar" & num)
  851.   set the locH of sprite extraHiderSpr to x
  852.   set the locV of sprite extraHiderSpr to y
  853.   updateStage()
  854.   if not stringp(arg1) then
  855.     set arg1 to EMPTY
  856.   end if
  857.   FlipCard(arg1)
  858. end
  859.  
  860. on removeextrahider
  861.   global extraHiderSpr
  862.   set the locH of sprite extraHiderSpr to -256
  863.   set the ink of sprite extraHiderSpr to 8
  864.   updateStage()
  865. end
  866.  
  867. on showBigNumber n
  868.   global extraHiderSpr
  869.   set the ink of sprite extraHiderSpr to 8
  870.   set the castNum of sprite extraHiderSpr to the number of cast ("bigNum" & n)
  871.   set the locH of sprite extraHiderSpr to 256
  872.   set the locV of sprite extraHiderSpr to 192
  873.   updateStage()
  874. end
  875.  
  876. on countAnswer gobackFrame
  877.   global answer, gName
  878.   countCharacters()
  879.   set n to value(answer)
  880.   showBigNumber(n)
  881.   playSound(string(n), 1)
  882.   playSound(formatName(gName, n), 1)
  883.   wait(60)
  884.   removeextrahider()
  885.   go(gobackFrame + 1)
  886. end
  887.  
  888. on playNextSound
  889.   global nextSound
  890.   playSound(item 1 of nextSound, 0)
  891.   put EMPTY into item 1 of nextSound
  892.   put EMPTY into char 1 of nextSound
  893.   if nextSound = EMPTY then
  894.     startTimer()
  895.   end if
  896. end
  897.  
  898. factory theFactory
  899.